﻿using AiMoRhino.ScriptInstance.LinkSelect;
using Rhino.DocObjects;
using Rhino.Geometry;

namespace AiMoCore
{
    partial class CSharpScriptInstance
    {
        public bool Link(out RhinoObject rhinoObject)
        {
            rhinoObject = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.RhinoObject, out LinkedOneItem link);
            if (re) rhinoObject = link.ResultRhinoObj;
            return re;
        }
        public bool Link(out RhinoObject[] rhinoObjects)
        {
            rhinoObjects = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.RhinoObject, out LinkedMultipleItem link);
            if (re) rhinoObjects = link.ResultRhinoObjs;
            return re;
        }
        public bool Link(out InstanceObject instanceObject)
        {
            instanceObject = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.InstanceObject, out LinkedOneItem link);
            if (re) instanceObject = link.ResultInstanceObj;
            return re;
        }
        public bool Link(out InstanceObject[] instanceObjects)
        {
            instanceObjects = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.InstanceObject, out LinkedMultipleItem link);
            if (re) instanceObjects = link.ResultInstanceObjs;
            return re;
        }
        public bool Link(out Point3d point)
        {
            point = Point3d.Unset;
            bool re = SelLinker.RegisterItem(LinkType.Point3d, out LinkedOneItem link);
            if (re) point = link.ResultPoint;
            return re;
        }
        public bool Link(out Point3d[] points)
        {
            points = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Point3d, out LinkedMultipleItem link);
            if (re) points = link.ResultPoints;
            return re;
        }
        public bool Link(out Polyline polyline)
        {
            polyline = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Polyline, out LinkedOneItem link);
            if (re) polyline = link.ResultPolyline;
            return re;
        }
        public bool Link(out Polyline[] polylines)
        {
            polylines = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Polyline, out LinkedMultipleItem link);
            if (re) polylines = link.ResultPolylines;
            return re;
        }
        public bool Link(out Circle circle)
        {
            circle = Circle.Unset;
            bool re = SelLinker.RegisterItem(LinkType.Circle, out LinkedOneItem link);
            if (re) circle = link.ResultCircle;
            return re;
        }
        public bool Link(out Circle[] circles)
        {
            circles = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Circle, out LinkedMultipleItem link);
            if (re) circles = link.ResultCircles;
            return re;
        }
        public bool Link(out Line line)
        {
            line = Line.Unset;
            bool re = SelLinker.RegisterItem(LinkType.Line, out LinkedOneItem link);
            if (re) line = link.ResultLine;
            return re;
        }
        public bool Link(out Line[] lines)
        {
            lines = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Line, out LinkedMultipleItem link);
            if (re) lines = link.ResultLines;
            return re;
        }
        public bool Link(out Curve curve)
        {
            curve = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Curve, out LinkedOneItem link);
            if (re) curve = link.ResultCurve;
            return re;
        }
        public bool Link(out Curve[] curves)
        {
            curves = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Curve, out LinkedMultipleItem link);
            if (re) curves = link.ResultCurves;
            return re;
        }
        public bool Link(out Mesh mesh)
        {
            mesh = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Mesh, out LinkedOneItem link);
            if (re) mesh = link.ResultMesh;
            return re;
        }
        public bool Link(out Mesh[] meshes)
        {
            meshes = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Mesh, out LinkedMultipleItem link);
            if (re) meshes = link.ResultMeshes;
            return re;
        }
        public bool Link(out Brep brep)
        {
            brep = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Brep, out LinkedOneItem link);
            if (re) brep = link.ResultBrep;
            return re;
        }
        public bool Link(out Brep[] breps)
        {
            breps = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Brep, out LinkedMultipleItem link);
            if (re) breps = link.ResultBreps;
            return re;
        }
        public bool Link(out Extrusion extrusion)
        {
            extrusion = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Extrusion, out LinkedOneItem link);
            if (re) extrusion = link.ResultExtrusion;
            return re;
        }
        public bool Link(out Extrusion[] extrusions)
        {
            extrusions = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Extrusion, out LinkedMultipleItem link);
            if (re) extrusions = link.ResultExtrusions;
            return re;
        }
        public bool Link(out Surface surface)
        {
            surface = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Surface, out LinkedOneItem link);
            if (re) surface = link.ResultSurface;
            return re;
        }
        public bool Link(out Surface[] surfaces)
        {
            surfaces = null;
            if (OnLoop) return false;
            bool re = SelLinker.RegisterItem(LinkType.Surface, out LinkedMultipleItem link);
            if (re) surfaces = link.ResultSurfaces;
            return re;
        }
    }
}